package collection;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

//Set集合演示:
public class SetDemo {
    public static void main(String[] args) {
        /*
        Set<String> set=new HashSet<>();
        set.add("one");
        set.add("two");
        set.add("three");
        set.add("four");
        set.add("five");
        //Set集合是不可重复集合,并且大部分无序
        System.out.println(set);//[four, one, two, three, five]
         */

        //小面试题:如何去重?
        List<String > list = new ArrayList<>();
        list.add("one");
        list.add("two");
        list.add("three");
        list.add("four");
        list.add("five");
        list.add("two");
        System.out.println(list);//[one, two, three, four, five, two]

        Set<String> set =new HashSet<>();
        set.addAll(list);
        System.out.println(set);//[four, one, two, three, five]




















    }
}
